package com.example.reporting.controller;

import com.example.reporting.service.ReportingService;
import com.example.reporting.vo.ReportingVo;
import com.example.result.CommonResult;
import com.example.utils.MyPageHelper;
import com.example.utils.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("reporting")
public class ReportingController {
    @Autowired
    ReportingService reportingService;
    /**
     * 收费管理-抄表全查
     * @return
     */
    @GetMapping("/getReporting")
    public CommonResult getReporting(@RequestParam String reportingName, PageRequest pageRequest){
        MyPageHelper.StartPage(pageRequest);
        CommonResult commonResult = reportingService.getReporting(reportingName);
        return commonResult;
    }
    /**
     * 收费管理-抄表删除
     */
    @DeleteMapping("/delReporting")
    public CommonResult delReporting(Integer id){
        int i = reportingService.delReporting(id);
        return CommonResult.ok(i);
    }
    /**
     * 收费管理-抄表增改
     */
    @PostMapping("/saveOrUpdateReporting")
    public CommonResult saveOrUpdateReporting(@RequestBody ReportingVo reportingVo){
        int i = reportingService.saveOrUpdateReporting(reportingVo);
        if(i>0){
            return CommonResult.ok();
        }else{
            return CommonResult.fail();
        }
    }

}
